
(import (scheme base)
        (scheme read)
        (scheme write)
        (scheme load)
        (srfi 27)
        (srfi 28))

(load "./name-gen.scm")

(random-source-randomize! default-random-source)

(define (list-random l)
  (list-ref l (random-integer (length l))))

;; Monster generator
(define monster-quantities
  '("one" "two" "three" "four" "five" "six"))

(define monster-qualities
  '("giant" "miniature" "fiery" "icy" "demonic"
    "underground" "flying" "lightning" "holy"
    "demonic" "horrific" "beautiful" "shadowy"
    "mechanical" "crafty" "tricky" "poisonous"))

(define hybrid-animals
  '("wolf" "cat" "dragon" "fish" "elephant" "bee" "human"
    "horse" "armadillo" "bird" "bat"))

(define body-parts
  '("eyes" "arms" "legs" "heads" "mouths" "ears"
    "torsos" "hands" "feet" "faces"))

(define monster-alignments
  '("Chaotic" "Lawful Evil" "Evil" "Chaotic Evil"))

(define monster-homes
  '("caves" "forests" "castles" "deserts" "graveyards"))

(define monster-combat-types
  '("magic" "brute force" "melee weapon" "ranged weapon"
    "poison gas" "ranged acid" "stealth"))

(define (make-hybrid)
  (define name (random-single-name))
  (define quality (list-random monster-qualities))
  (define alignment (list-random monster-alignments))
  (define a1 (list-random hybrid-animals))
  (define a2 (list-random hybrid-animals))
  (format "~a: A ~a half-~a half-~a that is ~a."
          name
          quality
          a1
          a2
          alignment))

(define (make-horror)
  (define horrors
    (let loop ((new-horror? #t)
               (horrors '()))
      (if new-horror?
          (loop (< 3 (random-integer 10))
                (cons (format "~a ~a, "
                              (list-random monster-quantities)
                              (list-random body-parts))
                      horrors))
          horrors)))
  (apply string-append
         (cons "It has "
               (reverse (cons
                         (format "and ~a ~a."
                                 (list-random monster-quantities)
                                 (list-random body-parts))
                         horrors)))))

(define (make-total-horror)
  (string-append
   (make-hybrid)
   " "
   (make-horror)
   " "
   (format "It lives in ~a."
           (list-random monster-homes))
   " "
   (format "It likes to fight with ~a."
           (list-random monster-combat-types))
   " "
   (format
    "Its intelligence is ~a, its difficulty is ~a, and its morale is ~a."
    (random-integer 10)
    (random-integer 10)
    (random-integer 10))))

